<#include '/admin/sonheader.html' >
<style>
 .layui-select-title input{
  width:100%;
 }
 .layui-unselect {
  width:50%;
 }
 .layui-form-radio {
  display: inline;
 }
 .layui-form-select dl{
 z-index:2000;
 max-height:200px;
 }
  .layui-form-pane .layui-input-block{
 	margin-left:130px;
 }
 .layui-form-pane .layui-form-label{
 width:130px
 }
</style>
<div class="main">
    <!--表单区域  -->
	<form id="advForm" class="layui-form layui-form-pane" action="" enctype="multipart/form-data">
		<input type="hidden" name="mstartdate" value="2015-01-01"/>
		<input type="hidden" name="menddate" value="2015-01-01"/>
  		<div class="layui-form-item">
    		<label class="layui-form-label">广告名称：</label>
    		<div class="layui-input-block">
      			<input type="text" id="advname" name="aname"  maxlength="30" lay-verify="aname" autocomplete="off" class="layui-input">
    		</div>
  		</div>
  		
  		<div class="layui-form-item">
			<label class="layui-form-label _stration">广告位置：</label>
    		<div class="layui-input-block">
      			<select  name="acid">
							<#list adColumnList as adc>
							<option value="${adc.acid }">${adc.cname }</option> </#list>
					</select>
   			</div>
  		</div>
  		
  		<div class="layui-form-item">
    		<label class="layui-form-label">广告链接：</label>
    		<div class="layui-input-block">
      			<input type="text" name="url"  maxlength="50"  lay-verify="url" autocomplete="off" class="layui-input">
    		</div>
    		<div class="layui-form-mid layui-word-aux" style="color:red;font-size: 12px;">例如：http://www.javamall.com.cn/version4/search-cat-86.html，只需填写search-cat-86.html即可！</div>
  		</div>
  		
  		<div class="layui-form-item">
    		<label class="layui-form-label">上传广告文件：</label>
    		<div class="layui-input-block">
      			<input type="file" id="file" name="pic" accept="image/*,.swf" lay-verify="" autocomplete="off" class="_upfile">
    		</div>
  		</div>
  		
  		<div class="layui-form-item">
    		<label class="layui-form-label">是否开启：</label>
    		<div class="layui-input-block">
      			<input type="radio" name="isclose" value="0" checked="checked" title="开启">
      			<input type="radio" name="isclose" value="1" title="关闭">
    		</div>
  		</div>
  		
  		<div class="layui-layer-btn layui-layer-btn-" style="padding:8px 12px;z-index:1000;position: fixed;left: 1px;width: 98%;height: 40px; background:rgba(230,230,230,0.8)"> 
  			<a class="layui-layer-btn0" type="submit" lay-submit="" lay-filter="save_adv">保存</a>
  			<a class="layui-layer-btn1">取消</a>
  		</div>
  	</form>
</div>
<script type="text/javascript">	
var index = parent.layer.getFrameIndex(window.name);

layui.use(['form', 'layedit', 'laydate'], function(){
    var form = layui.form()
        ,layer = layui.layer
        ,layedit = layui.layedit
        ,laydate = layui.laydate;
    
    
    form.verify({
    	aname:function(value){
    		if($.trim(value) == ""){
    			return "请输入广告名称";
    		}
    	},
    	url:function(value){
    		if($.trim(value) == ""){
    			return "请输入广告链接";
    		}
    	}
    });
    
    
    $(".layui-layer-btn1").click(function(){
    	parent.layer.close(index);
    });
    
    //监听提交
    form.on('submit(save_adv)', function(data){
    	var options = {
   			url:ctx+"/core/admin/adv/add-save.do",
   			type:"post",
   			dataType:"json",
   			success:function(data){
   				debugger;
   				if(data.result==1){	
   					$.Loading.success(data.message);
   					parent.layer.close(index); //再执行关闭        
   					parent.table.ajax.url(ctx+"/core/admin/adv/list-json.do?acid=${acid!''}").load();
   				} else {
   					$.Loading.error(data.message);
   				}
   			}
   		};
   		$("#advForm").ajaxSubmit(options);
       return false;
    });
});
</script>
